
import org.testng.annotations.DataProvider;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;

public class TestRockPaperScissors {
	
	private RockPaperScissors rps;
	private Player p1;
	private Player p2;
	
  @Test(dataProvider = "win")
  public void testWinPlay(RPSEnum p1, RPSEnum p2) {
	  assert rps.play(p1, p2) == Result.WIN;
  }
  
  @Test(dataProvider = "tie")
  public void testTiePlay(RPSEnum p1, RPSEnum p2) {
	  assert rps.play(p1, p2) == Result.TIE;
  }
  
  @Test(dataProvider = "lost")
  public void testLostPlay(RPSEnum p1, RPSEnum p2) {
	  assert rps.play(p1, p2) == Result.LOST;
  }
  
  @Test
  public void testPWinPlay() {
	  assert rps.play(p1, p2) == Result.WIN;
  }
  
  @Test
  public void testPTiePlay() {
	  assert rps.play(p1, p2) == Result.TIE;
  }
  
  @Test
  public void testPLostPlay() {
	  assert rps.play(p1, p2) == Result.LOST;
  }
  
  @DataProvider(name = "win")
  public Object[][] createWinData() {
   return new Object[][] {
     { RPSEnum.PAPER, RPSEnum.ROCK },
     { RPSEnum.ROCK, RPSEnum.SCISSORS},
     { RPSEnum.SCISSORS, RPSEnum.PAPER}
   };
  }

  @DataProvider(name = "tie")
  public Object[][] createTieData() {
   return new Object[][] {
     { RPSEnum.ROCK, RPSEnum.ROCK },
     { RPSEnum.SCISSORS, RPSEnum.SCISSORS},
     { RPSEnum.PAPER, RPSEnum.PAPER}
   };
  }
  
  @DataProvider(name = "lost")
  public Object[][] createLostData() {
   return new Object[][] {
     { RPSEnum.ROCK, RPSEnum.PAPER },
     { RPSEnum.SCISSORS, RPSEnum.ROCK},
     { RPSEnum.PAPER, RPSEnum.SCISSORS}
   };
  }
  
  @BeforeClass
  public void setUpClass() {
	  rps = new RockPaperScissors();
	  p1 = new Player("Barack");
	  p2 = new Player("Vladimir");
  }

  @AfterClass
  public void tearDownClass() {
	  rps = null;
	  p1 = null;
	  p2 = null;
  }

}
